package com.iie.bigVideo.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


/**
 * 设置虚拟路径，访问绝对路径下资源
 */
@Configuration
public class UploadConfig extends WebMvcConfigurerAdapter {


    @Value("${file.uploadFolder}")
    private String uploadFolder; // 静态资源实际存储路径
    @Value("${file.uploadImage}")
    private String uploadImage; // 实际存储图片路径
    @Value("${file.uploadVideo}")
    private String uploadVideo; // 实际存储视频路径

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        // 配置映射 uploadImage 路径到实际存储路径
//        registry.addResourceHandler(uploadImage + "/**")
//                .addResourceLocations("file:" + uploadFolder + uploadImage + "/");
//
//        // 配置映射 uploadVideo 路径到实际存储路径
//        registry.addResourceHandler(uploadVideo + "/**")
//                .addResourceLocations("file:" + uploadFolder + uploadVideo + "/");
//
//        // 配置映射 staticAccessPath 路径到实际存储路径
//        registry.addResourceHandler(staticAccessPath + "/**")
//                .addResourceLocations("file:" + uploadFolder + staticAccessPath + "/");
//        registry.addResourceHandler("/file/**").addResourceLocations("classpath:/upload_file/");
    }
}

